package com.ddxz.demo.quartz.controller;

import com.ddxz.demo.quartz.dto.GroupInfo;
import com.ddxz.demo.quartz.service.QuartzService;
import com.ddxz.tool.web.dto.DdxzResponse;
import org.springframework.web.bind.annotation.*;

/**
 * class description
 *
 * @author 朱宗刚
 * @version 1.0.0
 * @date 2020/11/24
 */

@RestController
public class QuartzController {
    @RequestMapping(value = "/task/save", method = RequestMethod.POST)
    public DdxzResponse saveTask(@RequestBody GroupInfo group) {
        return service.saveTask(group);
    }

    @RequestMapping(value = "/task/{groupId}/remove", method = RequestMethod.DELETE)
    public DdxzResponse removeTask(@PathVariable("groupId") String groupId) {
        return service.removeTask(groupId);
    }

    @RequestMapping(value = "/task/{groupId}/pause", method = RequestMethod.PUT)
    public DdxzResponse pauseTask(@PathVariable("groupId") String groupId) {
        return service.pauseTask(groupId);
    }

    @RequestMapping(value = "/task/{groupId}/resume", method = RequestMethod.PUT)
    public DdxzResponse resumeTask(@PathVariable("groupId") String groupId) {
        return service.resumeTask(groupId);
    }

    @RequestMapping(value = "/task/{groupId}/once", method = RequestMethod.GET)
    public DdxzResponse onceTask(@PathVariable("groupId") String groupId) {
        return service.onceTask(groupId);
    }



    private final QuartzService service;

    public QuartzController(QuartzService service) {
        this.service = service;
    }
}
